<?php
/**
 * The employee view.
 * @author Ryley France <daedzealot@gmail.com>
 * @version 1.0
 * @since 2013-12-03
 */
require_once 'login_info.php';
require_once 'database.php';
require_once 'employees.php';
require_once 'machines.php';

loginInfo::update_login ();

function display_employ ($eid) {
	$db = new database ();
	$employ = new employee ($eid);
	$employ->init($db);

	print "<tr>
<td>$employ->last_name</td>
<td>$employ->first_name</td>
<td>$employ->shift</td>
";

	$mach = new machine ($employ->machine);
	$mach->init ($db);

	print "<td>$mach->name</td>
</tr>
";

	$db->close();
}

?>

<html>
	<head>
		<title>Opol - Employee View</title>
	</head>
	<body>
		<link rel="stylesheet" type="text/css" href="opol.css">
		<?php require 'menu.php'; ?>
		<br>

<table border=\"1\">
	<tr>
	<td> Last Name </td>
	<td> First Name </td>
	<td> Shift </td>
	<td> Machine </td>
	</tr>

<?php
$db = new database();
$result = $db->query ("SELECT id FROM Employees ORDER BY last_name, first_name");
while ($row = $result->fetch_assoc()) {
	$id = $row['id'];
	display_employ ((int)$id);
}
$db->close();

?>
		</table>
	</body>
</html>